package com.atguigu.gulimall.ware.config;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author centurion
 * @description: MybatisPlus 配置类
 * @date 2024/6/3
 */
@Configuration
@MapperScan("com.atguigu.gulimall.ware.dao")
//开启事务
@EnableTransactionManagement
public class MybatisPlusConfig {
    /**
     * 添加分页插件
     *
     * Mybatis Plus 3.4.0版本之前
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        PaginationInterceptor interceptor = new PaginationInterceptor();
        //设置请求的页数大于最大页后的操作，true回到首页，false继续请求，默认false
        interceptor.setOverflow(true);
        //设置最大单页数量，默认500，-1不受限制
        interceptor.setLimit(1000);
        return interceptor;
    }
}
